using System;


namespace CUtil
{
	

	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
	public class IndicatorElement : IIndicatorElement //this does not work !! :ITradeCondition
	{

		#region private fields

		private double factor; // Buy or Sell
		private Operators  operatoR ;
		private Operators  operatorFactor ;
        private bool isShare;

		private string indicatorFunction;
		private int indicatorFunctionInterval;

        private string indicatorOrShare;
		private int indicatorInterval;
       
		#endregion

		#region constructor, dispose

		public IndicatorElement()
		{
			factor = 1F; 
			this.operatoR = Operators.plus;
			this.operatorFactor = Operators.times;

			indicatorFunction = string.Empty;
			indicatorFunctionInterval = 2;
			indicatorOrShare = string.Empty;
			indicatorInterval = 2;
			
		}
		#endregion

		#region public properties

		public double Factor 
		{
			get
			{
				return factor;
			}
			set
			{
				factor = value;
			}
		}
	
		public Operators OperatorFactor 
		{
			get
			{
				return operatorFactor;
			}
			set
			{
				operatorFactor = value;
			}
		}
        public bool IsShare
        {
            get
            {
                return isShare;
            }
            set
            {
                isShare = value;
            }
        }
   
        

		public Operators OperatoR 
		{
			get
			{
				return operatoR;
			}
			set
			{
				operatoR = value;
			}
		}
		public string OperatorString
		{
			get
			{
				switch (this.operatoR)
				{
					case Operators.plus:
					{
						return "+";
					}
					case (Operators.minus):
					{
						return "-";

					}
					case (Operators.times):
					{
						return "*";

					}
					case (Operators.quotient):
					{
						return "/";
					}
				}
				return "Error";
			}
			set
			{
				switch (value)
				{
					case "+":
					{
						this.operatoR = Operators.plus;
						break;

					}
					case "-":
					{
						this.operatoR = Operators.minus;
						break;

					}
					case "*":
					{
						this.operatoR = Operators.times;
						break;

					}
					case "/":
					{
						this.operatoR = Operators.quotient;
						break;

					}
				


			
				}
			}
		}
		public string OperatorFactorString
		{
			get
			{
				switch (this.operatorFactor)
				{
					case Operators.plus:
					{
						return "+";
					}
					case (Operators.minus):
					{
						return "-";

					}
					case (Operators.times):
					{
						return "*";

					}
					case (Operators.quotient):
					{
						return "/";
					}
				}
				return "Error";
			}
			set
			{
				switch (value)
				{
					case "+":
					{
						this.operatorFactor = Operators.plus;
						break;

					}
					case "-":
					{
						this.operatorFactor = Operators.minus;
						break;

					}
					case "*":
					{
						this.operatorFactor = Operators.times;
						break;

					}
					case "/":
					{
						this.operatorFactor = Operators.quotient;
						break;

					}
				


			
				}
			}
		}
		public string IndicatorFunction 
		{
			get
			{
				return indicatorFunction;
			}
			set
			{
				indicatorFunction = value;
			}
		}
		public int IndicatorFunctionInterval 
		{
			get
			{
				return indicatorFunctionInterval;
			}
			set
			{
				indicatorFunctionInterval = value;
			}
		}
		public string IndicatorOrShare 
		{
			get
			{
				return indicatorOrShare;
			}
			set
			{
                indicatorOrShare = value;
			}
		}
		public int IndicatorInterval 
		{
			get
			{
				return indicatorInterval;
			}
			set
			{
				indicatorInterval = value;
			}
		}
        public override string ToString()
        {
            return indicatorOrShare;

        }
		#endregion

	}
}
